<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BasePatientRelativeDetails {

	protected $m_intId;
	protected $m_strFirstName;
	protected $m_strMiddleName;
	protected $m_strLastName;
	protected $m_strMobileNumber;
	protected $m_strPhoneNumber;
	protected $m_strAddressLine1;
	protected $m_strAddressLine2;
	protected $m_strPatientRelationship;
	protected $m_strProfilePhotoPath;
	protected $m_strAddressProof;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getFirstName(){
		return $this->m_strFirstName;
	}

	public function getMiddleName(){
		return $this->m_strMiddleName;
	}

	public function getLastName(){
		return $this->m_strLastName;
	}

	public function getMobileNumber(){
		return $this->m_strMobileNumber;
	}

	public function getPhoneNumber(){
		return $this->m_strPhoneNumber;
	}

	public function getAddressLine1(){
		return $this->m_strAddressLine1;
	}

	public function getAddressLine2(){
		return $this->m_strAddressLine2;
	}

	public function getPatientRelationship(){
		return $this->m_strPatientRelationship;
	}

	public function getProfilePhotoPath(){
		return $this->m_strProfilePhotoPath;
	}

	public function getAddressProof(){
		return $this->m_strAddressProof;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setFirstName( $FirstName ){
		$this->m_strFirstName = $FirstName;
	}

	public function setMiddleName( $MiddleName ){
		$this->m_strMiddleName = $MiddleName;
	}

	public function setLastName( $LastName ){
		$this->m_strLastName = $LastName;
	}

	public function setMobileNumber( $MobileNumber ){
		$this->m_strMobileNumber = $MobileNumber;
	}

	public function setPhoneNumber( $PhoneNumber ){
		$this->m_strPhoneNumber = $PhoneNumber;
	}

	public function setAddressLine1( $AddressLine1 ){
		$this->m_strAddressLine1 = $AddressLine1;
	}

	public function setAddressLine2( $AddressLine2 ){
		$this->m_strAddressLine2 = $AddressLine2;
	}

	public function setPatientRelationship( $PatientRelationship ){
		$this->m_strPatientRelationship = $PatientRelationship;
	}

	public function setProfilePhotoPath( $ProfilePhotoPath ){
		$this->m_strProfilePhotoPath = $ProfilePhotoPath;
	}

	public function setAddressProof( $AddressProof ){
		$this->m_strAddressProof = $AddressProof;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into PATIENT_RELATIVE_DETAILS (first_name, middle_name, last_name, mobile_number, phone_number, address_line1, address_line2, patient_relationship, profile_photo_path, address_proof) values ('" . $this->getFirstName() . "', '" . $this->getMiddleName() . "', '" . $this->getLastName() . "', '" . $this->getMobileNumber() . "', '" . $this->getPhoneNumber() . "', '" . $this->getAddressLine1() . "', '" . $this->getAddressLine2() . "', '" . $this->getPatientRelationship() . "', '" . $this->getProfilePhotoPath() . "', '" . $this->getAddressProof() . "')");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE PATIENT_RELATIVE_DETAILS set  first_name= '" . $this->getFirstName() . "', middle_name= '" . $this->getMiddleName() . "', last_name= '" . $this->getLastName() . "', mobile_number= '" . $this->getMobileNumber() . "', phone_number= '" . $this->getPhoneNumber() . "', address_line1= '" . $this->getAddressLine1() . "', address_line2= '" . $this->getAddressLine2() . "', patient_relationship= '" . $this->getPatientRelationship() . "', profile_photo_path= '" . $this->getProfilePhotoPath() . "', address_proof= '" . $this->getAddressProof() . "' where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM patient_relative_details WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'patient_relative_details'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}